

package org.jhotdraw.app.action.file;

import java.net.URI;

import javax.swing.JOptionPane;
import org.jhotdraw.app.Application;
import org.jhotdraw.app.View;
import org.jhotdraw.draw.Drawing;
import org.jhotdraw.gui.URIChooser;
import org.jhotdraw.util.ResourceBundleUtil;

import stateDiagram.SimulationEngine;
import stateDiagram.StateDiagramView;

public class SimulateDrawingAction extends LoadFileAction{

	public final static String ID = "file.simulateDrawing";
	
	public SimulateDrawingAction(Application app, View view) {
		super(app, view);
		ResourceBundleUtil labels = ResourceBundleUtil.getBundle("stateDiagram.Labels");
        labels.configureAction(this, ID);
	}

	@Override
	public void loadViewFromURI(final View view, final URI uri, final URIChooser chooser) {
		SimulationEngine s = new SimulationEngine();
		String results = new String();
		Drawing drawing = ((StateDiagramView) this.getActiveView()).getEditor().getActiveView().getDrawing();
		results = s.simulate(drawing, uri);
		//System.out.println(results);
		JOptionPane.showMessageDialog(view.getComponent(),("" + results));
	}
	
	
}
